package com.hk.blog.controller;

import com.hk.commons.JsonResult;
import com.hk.core.authentication.api.menus.Menu;
import com.hk.core.authentication.api.menus.MenuManager;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Kevin
 * @date 2022-06-20 20:50
 */
@RestController
@RequestMapping("index")
@RequiredArgsConstructor
public class IndexController {

    private final MenuManager menuManager;

    @GetMapping("")
    public JsonResult<?> ping() {
        return JsonResult.success();
    }

    @GetMapping("menu")
    public JsonResult<List<Menu>> getCurrentMenu() {
        List<Menu> menu = menuManager.getCurrentUserMenu();
        return JsonResult.success(menu);
    }
}
